<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root" >
        <div style="border: black 1px solid;">
            <con1></con1>
        </div>
        <p>{{firstName}}</p>
        <p>{{firstAge}}</p>
        <button @click='fn'>btn</button>
    </div>
</body>
<script src="./vue-feifei.js"></script>
<script>
    // 组件之间的依赖收集和派发更新是自治的
    //在一个组件中，组件中的一个数据发生变化，就会触发set函数进行派发更新重新进行
    //视图的渲染，然后这个组件的数据重新进行依赖的收集。
    Vue.component('con1',{
        template: '<div> <p>{{lastName}}</p> <button @click="fn2">click me</button></div>',
        data() {
            return {
                lastName: 'two'
            }
        },
        methods: {
            fn2() {
               this.lastName = Math.random() 
            }
        },
    })
    let vue = new Vue({
        el:'#root',
        data() {
            return {
                firstName: 'oneComponent',
                firstAge:20
            }
        },
        methods: {
            fn() {
               this.firstAge = Math.random() 
            }
        },
    })
</script>
</html>